package me.yuxiaoyao.example.jpa.nativesql.repository;

import me.yuxiaoyao.example.jpa.nativesql.entity.NativeSql;
import me.yuxiaoyao.example.jpa.nativesql.entity.dto.CustomDTO;
import me.yuxiaoyao.example.jpa.nativesql.entity.dto.NativeSqlDTO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author kerryzhang on 2020/12/16
 */


@Repository
public interface NativeSqlRepository extends JpaRepository<NativeSql, Long> {

    @Query(nativeQuery = true, value = "select id,name as custom from native_sql")
    List<CustomDTO> findCustom();

    @Query(nativeQuery = true, value = "select * from native_sql")
    List<NativeSqlDTO> findAllDTO();

}
